#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>


extern char** environ; 

int main()
{
    putenv("MYENV=111");
    pid_t id = fork();

    if (id == 0)
    {
       printf("before,I am a process,pid: %d,ppid: %d\n",getpid(),getppid());
       //sleep(3);
        
       char* const myargv[] = {"ls","-a","-l",NULL};

       char* const myenv[] = {"x=1","y=2","z=3",NULL};
      //int ret = execl("/usr/bin/ls","ls","-a","-l",NULL);

      // execl("/usr/bin/top","top",NULL);
      //
   //  int ret = execv("/usr/bin/ls",myargv);

       // execl("./otherExe","otherExe",NULL);
       //
       //execl("/usr/bin/python3","python3","test.py",NULL);
       execle("./otherExe","otherExe","-a","l",NULL,myenv);
       exit(1);
    }
    
    pid_t ret = waitpid(id,NULL,0);

    if (ret > 0)
    {
        printf("wait sucess,father pid: %d,ret id: %d\n",getpid(),ret);
    }

    //sleep(3);

    return 0;
}

